package br.com.conjuntos;

import java.util.Set;
import java.util.TreeSet;

class J implements Comparable{
	String nome;
	Integer rg;
	
	J(String nome, int rg){
		this.nome = nome;
		this.rg = rg;
	}
	public String toString(){
		return nome + " " + rg + " ";
	}
	@Override
	public int compareTo(Object o) {		
		return this.rg.compareTo(((J)o).rg);	
	}
	
}
public class Programa10 {
	public static void main(String[] args) {
		Set s = new TreeSet();
		J a = new J("Osvaldo", 123);
		J b = new J("Gomes",234);
		J c = new J("Sergio",256);
		J d = new J("Edu",123);
		s.add(a);
		s.add(d);
		s.add(b);
		s.add(c);
		System.out.println(s);
		System.out.println(s.size());
		
	}
}
